# CC = g++
# RM = RM
# EXE = simple

# OJBS = main.o test1.o
# $(EXE):$(OJBS)
# 	$(CC) -o $@ $^ -std=c++11
# main.o:main.cpp
# 	$(CC) -c $^
# test1.o:test1.cpp
# 	$(CC) -c $^

# .PHONY:clean
# clean:
# 	rm -rf $(EXE)

# 改进
CC = g++
EXE = simple
# 使用wildcard获取全部的.cpp文件或者.h文件
SRCS = $(wildcard *.cpp)

# 使用patsubst进行字符串替换,将文件后缀替换伪.o
# OBJS = $(patsubst %.cpp,%.o,$(SRCS))
# 或者使用 
OBJS = $(SRCS:.cpp=.o)

$(EXE):$(OBJS)
	$(CC) -o $@ $^ -std=c++11
%.o:%.cpp
	$(CC) -c $^

.PHONY:clean
clean:
	rm -rf $(EXE)